package com.huawei.appgallery.foundation.ui.css.adapter;

import android.view.View;
import com.huawei.appgallery.foundation.ui.css.CSSDeclaration;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.adapter.param.MethodSignature;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;

public abstract class RenderAdapter {
    public abstract MethodSignature getMethod(String str);

    public void render(View view, CSSRule cSSRule) {
        CSSDeclaration styleDeclaration = cSSRule.getStyleDeclaration();
        for (int i = 0; i < styleDeclaration.getLength(); i++) {
            String propertyName = styleDeclaration.getPropertyName(i);
            CSSValue propertyValue = styleDeclaration.getPropertyValue(propertyName);
            if (propertyValue != null) {
                MethodSignature method = getMethod(propertyName);
                if (method != null) {
                    method.invoke(view, propertyValue);
                }
            }
        }
    }
}
